package cn.ytnet.shangyun.service.basic.entity;

import org.springframework.stereotype.Component;

import javax.persistence.*;

/**
 * Created by cyongk on 2015/12/8.
 * ClassName：GoodsCodeEntity
 * ChineseName：商品条码类
 */
@Component("goodsCodeEntity")
@Entity
@Table(name = "T_GoodsCode", schema = "crebas", catalog = "")
public class GoodsCodeEntity {
    private String pkTGoodscodeId;
    private int codeState;

    private GoodsEntity goodsEntity;//商品

    @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
    @JoinColumn(name = "pk_t_goods_storecode")
    public GoodsEntity getGoodsEntity() {
        return goodsEntity;
    }

    public void setGoodsEntity(GoodsEntity goodsEntity) {
        this.goodsEntity = goodsEntity;
    }

    @Id
    @Column(name = "pk_t_goodscode_id", nullable = false, length = 18)
    public String getPkTGoodscodeId() {
        return pkTGoodscodeId;
    }

    public void setPkTGoodscodeId(String pkTGoodscodeId) {
        this.pkTGoodscodeId = pkTGoodscodeId;
    }

    @Basic
    @Column(name = "code_state", nullable = false)
    public int getCodeState() {
        return codeState;
    }

    public void setCodeState(int codeState) {
        this.codeState = codeState;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        GoodsCodeEntity that = (GoodsCodeEntity) o;

        if (codeState != that.codeState) return false;
        return pkTGoodscodeId != null ? pkTGoodscodeId.equals(that.pkTGoodscodeId) : that.pkTGoodscodeId == null;

    }

    @Override
    public int hashCode() {
        int result = pkTGoodscodeId != null ? pkTGoodscodeId.hashCode() : 0;
        result = 31 * result + codeState;
        return result;
    }
}
